//
//  DXWTagCell.m
//  BuDeJie
//
//  Created by 淡馨慰 on 16/7/31.
//  Copyright © 2016年 淡馨慰. All rights reserved.
//

#import "DXWTagCell.h"
#import <SDWebImage/UIImageView+WebCache.h>
#import "DXWTagItem.h"

#define iconW self.iconImageView.image.size.width
@interface DXWTagCell ()

@property (weak, nonatomic) IBOutlet UIImageView *iconImageView;

@property (weak, nonatomic) IBOutlet UILabel *theme_Label;

@property (weak, nonatomic) IBOutlet UILabel *number_Label;

@end

@implementation DXWTagCell

- (void)setFrame:(CGRect)frame
{
    //将高为71的cell减1,漏出背景色当分割线
    frame.size.height -= 10;
    frame.origin.y += 10;
    frame.origin.x += 10;
    frame.size.width -= 20;

    [super setFrame:frame];
}

-(void)setItem:(DXWTagItem *)item
{
    _item = item;
    //1.发送网络请求获取头像
    NSURL *iconURL = [NSURL URLWithString:item.image_list];
    [self.iconImageView sd_setImageWithURL:iconURL];
    //2.主题
    self.theme_Label.text = item.theme_name;
    //3.订阅数
    //都超过万,转换成"万人",若都没超过,还要进行判断
    CGFloat number = item.sub_number.floatValue;
    if(number > 10000)
    {
    number = number / 10000.0;
    self.number_Label.text = [NSString stringWithFormat:@"%.1f万人订阅",number];
        //更改后的值一定要传递回去
        //不需要再判断里面是否含.0,直接替换
            self.number_Label.text = [self.number_Label.text stringByReplacingOccurrencesOfString:@".0" withString:@""];

         }
    else
    self.number_Label.text = [NSString stringWithFormat:@"%f人订阅",number];

}

@end
